package com.dong.c09_netty_unpooled;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.util.CharsetUtil;

/**
 * <h1></h1>
 *
 * @author : dzj
 * @create: 2021-03-09 00:03,
 */
public class ByteBuf02 {
    public static void main(String[] args) {
        ByteBuf byteBuf = Unpooled.copiedBuffer("hello,world!", CharsetUtil.UTF_8);
        if(byteBuf.hasArray()) {
            byte[] content = byteBuf.array();
            System.out.println(new String(content));
            System.out.println("byteBuf:"+byteBuf);
            System.out.println("readIndex:"+byteBuf.readerIndex());
            System.out.println("writeIndex:"+byteBuf.writerIndex());
            System.out.println("capacity:"+byteBuf.capacity());
            int len = byteBuf.readableBytes();
        }
    }
}
